<?php
/**
 * Created by PhpStorm.
 * User: Kevin
 * Date: 2018/9/29
 * Time: 15:40
 */
namespace app\admin\model;
use think\Db;
use think\Model;
class MaterModel extends Model
{
    protected $name = 'shop_order';

    public function getMaterData($map,$Nowpage, $limits){
        return $this->alias ('so')
            ->join('shops ss','so.so_shop_id = ss.s_id','left')
            ->where($map)
            ->field('s_id,s_name,s_phone,s_address,so_id,so_number,so_num,so_money,so_status,so_time,so_paytime,so_type,so_in_out,so_send_status,so_jifen,so_wuliu_name,so_wuliu_num')
            ->page($Nowpage,$limits)
            ->select();
    }

    public function getMaterCount($map){
        return $this->alias ('so')
            ->join('shops ss','so.so_shop_id = ss.s_id','left')
            ->where($map)
            ->count();
    }

    public function getOrderDetail($map){
        $data = $this->alias ('so')
            ->join('shops ss','so.so_shop_id = ss.s_id','left')
            ->where($map)
            ->field('s_id,s_name,s_phone,s_address,so_id,so_number,so_num,so_money,so_status,so_time,so_paytime,so_type,so_send_status,so_jifen,so_in_out')
            ->find();
        if(!empty($data)){
            $info = Db::name('shop_order_info')
                ->where('oi_so_id',$data['so_id'])
                ->field('oi_id,oi_num,oi_good_money,oi_jifen,oi_good_name')
                ->select();
        }
        $data['info'] = $info;
        return $data;
    }
}